package com.gaogzhen.juc.visibility.volatileTest;

public class Test06 {
    volatile static int x;
    static int y;

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            y = 20;
            x = 10;
        }, "t1");
        t1.start();

        Thread t2 = new Thread(() -> {
            // x = 10对t2可见，同时y = 20对t2也是可见的
            System.out.println(x);
        }, "t2");
        t2.start();
    }
}
